package com.atomos.strategy.action.velocity
{
	import flash.geom.Point;
	
	import com.atomos.particle.Particle;
	import com.atomos.strategy.action.AbstractAction;
	import com.atomos.strategy.action.ActionStrategy;
	import com.atomos.utils.PointUtils;		

	public class PonctualForceAction extends AbstractAction implements ActionStrategy
	{
		protected var _pForcePosition : Point;
		protected var _nForceStrength : Number;
		protected var _nForceRadius : Number;
		
		public function PonctualForceAction( forcePosition : Point = null, forceRadius : Number = 0, forceStrength : Number = 0 )
		{
			setForcePosition( forcePosition );
			setForceRadius( forceRadius );
			setForceStrength( forceStrength );
		}
		public override  function process( particle : Particle ) : void
		{
			var pForce : Point = particle.position.clone().subtract( _pForcePosition );
			var distLength : Number = pForce.length;
			
			if( distLength > _nForceRadius ) return;
			
			var l : Number = _nForceStrength * _nTimeStep;
			
			pForce.normalize( l );			
			particle.velocity = particle.velocity.add( pForce );
		}
		
		public function setForcePosition ( forcePosition : Point ) : void
		{
			_pForcePosition = forcePosition ? forcePosition : new Point();
		} 
		public function getForcePosition () : Point
		{
			return _pForcePosition;
		}
		
		public function setForceRadius ( forceRadius : Number ) : void
		{
			_nForceRadius = isNaN( forceRadius ) ? 0 : forceRadius;
		}
		public function getForceRadius () : Number
		{
			return _nForceRadius;
		}
		
		public function setForceStrength ( forceStrength : Number ) : void
		{
			_nForceStrength = isNaN( forceStrength ) ? 0 : forceStrength;
		}
		public function getForceStrength () : Number
		{
			return _nForceStrength;
		}
	}
}